home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
network
/
exp16116.zip
/
NEW.ZIP
/
HEAD.ASM
< prev
next >
Wrap
Assembly Source File
|
1994-04-06
|
37KB
|
1,445 lines
include defs.asm
; Copyright, 1988-1993, Russell Nelson, Crynwr Software
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, version 1.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
code segment word public
assume cs:code, ds:code
public phd_environ
org 2ch
phd_environ dw ?
public phd_dioa
org 80h
phd_dioa label byte
org 100h
start:
jmp start_1
extrn start_1: near
db "PK"
extrn branding_msg: byte
dw branding_msg
even ;put the stack on a word boundary.
dw 128 dup(?) ;128 words of stack.
our_stack label byte
extrn int_no: byte
public entry_point, sys_features, flagbyte, is_186, is_286, is_386
entry_point db ?,?,?,? ; interrupt to communicate.
sys_features db 0 ; 2h = MC 40h = 2nd 8259
is_186 db 0 ;=0 if 808[68], =1 if 80[123]86.
is_286 db 0 ;=0 if 80[1]8[68], =1 if 80[234]86.
is_386 db 0 ;=0 if 80[12]8[68], =1 if 80[34]86.
flagbyte db 0
original_mask db 0 ;=0 if interrupt was originally on.
even
functions label word
dw f_not_implemented ;0
dw f_driver_info ;1
dw f_access_type ;2
dw f_release_type ;3
dw f_send_pkt ;4
dw f_terminate ;5
dw f_get_address ;6
dw f_reset_interface ;7
dw f_stop ;8
dw f_not_implemented ;9
dw f_get_parameters ;10
dw f_not_implemented ;11
dw f_as_send_pkt ;12
dw f_drop_pkt ;13
dw f_not_implemented ;14
dw f_not_implemented ;15
dw f_not_implemented ;16
dw f_not_implemented ;17
dw f_not_implemented ;18
dw f_not_implemented ;19
dw f_set_rcv_mode ;20
dw f_get_rcv_mode ;21
dw f_set_multicast_list ;22
dw f_get_multicast_list ;23
dw f_get_statistics ;24
dw f_set_address ;25
;external data supplied by device-dependent module:
extrn driver_class: byte
extrn driver_type: byte
extrn driver_name: byte
extrn driver_function: byte
extrn parameter_list: byte
extrn rcv_modes: word ;count of modes followed by mode handles.
;external code supplied by device-dependent module:
extrn send_pkt: near
extrn as_send_pkt: near
extrn drop_pkt: near
extrn set_address: near
extrn terminate: near
extrn reset_interface: near
extrn xmit: near
extrn recv: near
extrn etopen: near
extrn set_multicast_list: near
extrn timer_isr: near
per_handle struc
in_use db 0 ;non-zero if this handle is in use.
packet_type db MAX_P_LEN dup(0);associated packet type.
packet_type_len dw 0 ;associated packet type length.
receiver dd 0 ;receiver handler.
receiver_sig db 8 dup(?) ;signature at the receiver handler.
class db ? ;interface class
per_handle ends
handles per_handle MAX_HANDLE dup(<>)
end_handles label byte
public multicast_count, multicast_addrs, multicast_broad
multicast_count dw 0 ;count of stored multicast addresses.
multicast_broad db 0ffh,0ffh,0ffh,0ffh,0ffh,0ffh ; entry for broadcast
multicast_addrs db MAX_MULTICAST*EADDR_LEN dup(?)
;the device-dependent code reads the board's address from ROM in the
;initialization code.
public address_len, rom_address, my_address
address_len dw EADDR_LEN ;default to Ethernet.
rom_address db MAX_ADDR_LEN dup(?) ;our address in ROM.
my_address db MAX_ADDR_LEN dup(?) ;our current address.
rcv_mode_num dw 3
free_handle dw 0 ; temp, a handle not in use
found_handle dw 0 ; temp, handle for our packet
receive_ptr dd 0 ; the pkt receive service routine
public send_head, send_tail
send_head dd 0 ; head of transmit queue
send_tail dd 0 ; tail of transmit queue
statistics_list label dword
packets_in dw ?,?
packets_out dw ?,?
bytes_in dw ?,?
bytes_out dw ?,?
errors_in dw ?,?
errors_out dw ?,?
packets_dropped dw ?,? ;dropped due to no type handler.
savespss label dword
savesp dw ? ;saved during the stack swap.
savess dw ?
their_recv_isr dd 0 ; original owner of board int
their_timer dd 0
;
; The following structure is used to access the registers pushed by the
; packet driver interrupt handler. Don't change this structure without also
; changing the "bytes" structure given below.
;
regs struc ; stack offsets of incoming regs
_ES dw ?
_DS dw ?
_BP dw ?
_DI dw ?
_SI dw ?
_DX dw ?
_CX dw ?
_BX dw ?
_AX dw ?
_IP dw ?
_CS dw ?
_F dw ? ; flags, Carry flag is bit 0
regs ends
;
; bits in the _F register.
;
CY equ 0001h
EI equ 0200h
;
; This structure is a bytewise version of the "regs" structure above.
;
bytes struc ; stack offsets of incoming regs
dw ? ; es, ds, bp, di, si are 16 bits
dw ?
dw ?
dw ?
dw ?
_DL db ?
_DH db ?
_CL db ?
_CH db ?
_BL db ?
_BH db ?
_AL db ?
_AH db ?
bytes ends
public their_isr
their_isr dd 0 ; original owner of pkt driver int
public our_isr
our_isr:
jmp short our_isr_0 ;the required signature.
nop
db 'PKT DRVR',0
our_isr_open:
push ax ; save lots of registers
push bx
push cx
push dx
push si
push di
push bp
push ds
push es
call etopen ; init the card
jc our_isr_no_init
mov si,offset rom_address ;copy their original address to
movseg es,ds
mov di,offset my_address ; their current address.
mov cx,MAX_ADDR_LEN/2
rep movsw
cmp rcv_modes+2[3*2],0 ;does mode 3 exist?
stc ;make sure we generate an error!
je our_isr_no_init ;no.
call rcv_modes+2[3*2] ; call it.
clc
our_isr_no_init:
pop es ; restore lots of registers
pop ds
pop bp
pop di
pop si
pop dx
pop cx
pop bx
pop ax
mov dh,CANT_RESET ; (actually can't initialize)
jc our_isr_error
or flagbyte,CALLED_ETOPEN ; remember this fact
jmp short our_isr_cont
our_isr_0:
assume ds:nothing
push ax
push bx
push cx
push dx
push si
push di
push bp
push ds
push es
cld
mov bx,cs ;set up ds.
mov ds,bx
assume ds:code
mov bp,sp ;we use bp to access the original regs.
and _F[bp],not CY ;start by clearing the carry flag.
if 0
test _F[bp],EI ;were interrupt on?
jz our_isr_ei ;no, don't turn them back on.
sti ;yes, turn them back on.
our_isr_ei:
endif
test flagbyte,CALLED_ETOPEN ; have we initialized the card?
jz our_isr_open ; no
our_isr_cont:
mov bl,ah ;jump to the correct function.
xor bh,bh
cmp bx,25 ;only twenty five functions right now.
ja f_bad_command
add bx,bx ;*2
;
; The functions are called with all the original registers except
; BX, DH, and BP. They do not need to preserve any of them. If the
; function returns with cy clear, all is well. Otherwise dh=error number.
;
call functions[bx]
assume ds:nothing
jc our_isr_error
our_isr_return:
pop es
pop ds
pop bp
pop di
pop si
pop dx
pop cx
pop bx
pop ax
iret
our_isr_error:
assume ds:nothing
mov bp,sp ;we use bp to access the original regs.
mov _DH[bp],dh
or _F[bp],CY ;return their carry flag.
jmp short our_isr_return
f_bad_command:
assume ds:code
extrn bad_command_intercept: near
mov bx,_BX[bp]
call bad_command_intercept
mov _BX[bp],bx
mov _DX[bp],dx
jnc our_isr_return
jmp our_isr_error
public re_enable_interrupts
re_enable_interrupts:
; Possibly re-enable interrupts. We put this here so that other routines
; don't need to know how we put things on the stack.
test _F[bp], EI ; Were interrupts enabled on pkt driver entry?
je re_enable_interrupts_1 ; No.
sti ; Yes, re-enable interrupts now.
re_enable_interrupts_1:
ret
f_not_implemented:
mov dh,BAD_COMMAND
stc
ret
f_driver_info:
; As of 1.08, the handle is optional, so we no longer verify it.
; call verify_handle
cmp _AL[bp],0ffh ; correct calling convention?
jne f_driver_info_1 ; ne = incorrect, fail
;Fo